package com.kfm.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

// 过滤的请求
@WebFilter("/*")
public class CharsetEncodingFilter implements Filter {


    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {


        if (request instanceof HttpServletRequest httpServletRequest){
            httpServletRequest.setCharacterEncoding("utf-8");
            httpServletRequest.getSession();
        }


        chain.doFilter(request, response);
    }
}
